require('./main.less');
require('src/main.js');
const { postSystemVersion } = require('doapis/others/others.js');

let downloadURL = '';

$('#qrcode').attr('src', 'http://120.79.186.151:8080/grinok_source/home_source/download_APP.jpg');

$(document).ready(function() {
    postSystemVersion().then(function(res) {
        const data = res.data;
        $('#version').text('V' + data.versiones);
        $('#fileSize').text(data.fileSize+' M');
        $('#updateDate').text($.$getFormatMD(data.createTime));
        $('#qrcode').attr('src', data.remark2);
        downloadURL = data.linkUrl;
    });
    $('#download').click(function() {
        // 如果是微信浏览器打开，则弹出去浏览器下载的提示，否则直接下载
        if ($.$hasBrowserType('WEIXIN')) {
            $('#weixinTips').fadeIn();
        } else {
            $.showLoad('body');
            setTimeout(function() {
                downloadURL ? window.location.href = downloadURL : alert('获取下载地址失败！！');
                $.hideLoad();
            }, 1300);
        }
    });
    // 隐藏微信浏览器下打开浏览器下载的提示
    $('#hideTips').click(function() {
        $('#weixinTips').fadeOut();
    });
});
